import http from '../utils/http'
import store from '../store'

export function login(option){
  return http.post('/user/login',option).then(data=>{
    if(data.code == 0){
      store.commit('initUserInfo',data.data)
    }
    return data 
  })
}

export function getCode(option){
  return http.post('/user/code',{
    phone:option
  })
}


export function reg(option){
  return http.post('/user/register',option)
}

export function signout(){
  return http.get('/user/signout').then(data=>{
    if(data.code == 0){
      store.commit('initUserInfo',{})
    }
    return data
  })
}